<?php include("config.php");

// Requesting data from PAD submission form on submit.php
$padurl       = trim($_POST["padurl"]);
$aflform      = $_POST["affiliate"];
$aflidform    = $_POST["affiliateid"];
$backlink     = $_POST["backlink"];
$securitycode = strtoupper(trim($_POST["securitycode"]));
//$padcat       = $_POST["padcat"];
$submit       = $_POST["submit"];
if(empty($submit)) { // If this page called directly
	header("Location: submit.php"); // Redirecting to program submission page
	exit;
}
else {
	session_start();
	if(!isset($_SESSION["SecurityCode"])) { // If no security code on server generated (illegal access)
		die ("<p><b>Illegal form access!</b></p>\n");
	}
}
?>
<?php include("header.inc"); ?>

<link rel="stylesheet" type="text/css" href="<?php echo $cssfile; ?>">
<script language="javascript">
<!--
function collapseAll() {
	var LItems=document.getElementById("catlist").getElementsByTagName("li");
	for(o=0; o<LItems.length; o++) {
		if(LItems[o].className=="open") {
			LItems[o].className="close";
		}
		if(LItems[o].getElementsByTagName("ul").length>0) {
			curChilds=LItems[o].getElementsByTagName("span");
			if(curChilds.length>0) {
				curChilds[0].onclick=function() {
					ShowHide(this.parentNode);
				}
				if(curChilds[0].className=="open") {
					curChilds[0].className="close";
				}
			}
			curChilds=LItems[o].getElementsByTagName("a");
			if(curChilds.length>0) {
				curChilds[0].onclick=function() {
					ShowHide(this.parentNode);
					return false;
				}
			}
		}
	}
}

function ShowHide(curHeader) {
	if(curHeader.className=="close") {
		curHeader.className="open";
	}
	else if(curHeader.className=="open") {
		curHeader.className="close";
	}
}
//-->
</script>
</head>
<body onLoad="collapseAll();">
<table bgcolor="White" width="980" align="center">
<tr><td width="180" valign="top">
<table width=180 border=0 cellpadding=0 cellspacing=0 background="images/middle.gif">
          <tbody>
            <tr>
              <td height="2" class="table-top"></td>
            </tr>
            <tr>
              <td align=left valign=top class="left">
<?php
$which_class = "Audio & Multimedia";
include_once('categories1.inc');
?>
</td>
            </tr>
            <tr>
              <td height="8" class="table-bottom"></td>
            </tr>
          </tbody>
        </table>
      <br>
        <table width=180 
            border=0 align="center" cellpadding=0 cellspacing=0 
            background="images/middle.gif">
          <tbody>
            <tr>
              <td width="8" height="2" class="table-top"></td>
              <td width="172" class="table-top"></td>
            </tr>
            <tr>
              <td align=left valign=center class="left-rss">:<br>
                  <br>
                  <p></p>
                <p></p></td>
              <td align=left valign=center class="left-rss"><span class="left-b"><img src="images/rss.gif" width="36" height="14">RSS Feeds</span><br>
                <img src="images/rss-1.gif" alt="new" width="14" height="14"><a href="rss.php">New Releases and Updates</a><br>
                  <img src="images/rss-1.gif" alt="new" width="14" height="14"><a href="rss.php?feed=popular">Most Popular Software</a><br>
                  <img src="images/rss-1.gif" alt="new" width="14" height="14"><a href="rss.php?feed=rating">Top Rated Software</a></td>
            </tr>
            <tr>
              <td height="8" colspan="2" class="table-bottom"></td>
            </tr>
          </tbody>
        </table>
&nbsp;</td><td valign="top">
<?php

// Checking PAD URL field
if(empty($padurl) or (strtolower($padurl) == "http://")) {
	$bad = "You did not enter PAD URL!<br>";
}
// Checking affiliate program fields
if($affiliate && empty($affiliateid)) {
	$bad = "You did not enter Affiliate ID for selected Affiliate Provider!<br>";
}
// Checking the back link url
if(empty($backlink) or (strtolower($backlink) == "http://")) {
	$backlink = "";
}
else {
	if(!($backlinkdata = @file($backlink))) {
		$bad.= "Error opening Back Link Page URL!<br>";
	}
	else {
		$backlinkdata = implode("",$backlinkdata);
		if (strstr($backlinkdata, "http://" . $_SERVER['HTTP_HOST']) === FALSE) {
			$bad.= "Back Link to http://" . $_SERVER['HTTP_HOST'] . " on established Back Link Page URL was NOT found!<br>";
		}
	}
}
if(empty($securitycode)) { // If the security code field is empty
	$bad.= "You did not enter the security code!<br>";
}
if($securitycode != $_SESSION["SecurityCode"]) { // If the security code does not match the generated one
	$bad.= "The security code is wrong!<br>";
}
if($bad) { // If there was any problem with filling the form
	echo "<h2 class=\"red\">" . $bad . "</h2>\n";
	echo "<p><b>Please go <a href=\"javascript:history.back()\">Back</a> and fill the form correctly.</b></p>\n";
	exit;
}
$reqtags = array("<XML_DIZ_INFO><COMPANY_INFO><COMPANY_NAME>",
                 "<XML_DIZ_INFO><COMPANY_INFO><COUNTRY>",
                 "<XML_DIZ_INFO><COMPANY_INFO><COMPANY_WEBSITE_URL>",
                 "<XML_DIZ_INFO><COMPANY_INFO><CONTACT_INFO><CONTACT_FIRST_NAME>",
                 "<XML_DIZ_INFO><COMPANY_INFO><CONTACT_INFO><CONTACT_LAST_NAME>",
                 "<XML_DIZ_INFO><COMPANY_INFO><CONTACT_INFO><CONTACT_EMAIL>",
                 "<XML_DIZ_INFO><PROGRAM_INFO><PROGRAM_NAME>",
                 "<XML_DIZ_INFO><PROGRAM_INFO><PROGRAM_VERSION>",
                 "<XML_DIZ_INFO><PROGRAM_INFO><PROGRAM_RELEASE_MONTH>",
                 "<XML_DIZ_INFO><PROGRAM_INFO><PROGRAM_RELEASE_DAY>",
                 "<XML_DIZ_INFO><PROGRAM_INFO><PROGRAM_RELEASE_YEAR>",
                 "<XML_DIZ_INFO><PROGRAM_INFO><PROGRAM_COST_DOLLARS>",
                 "<XML_DIZ_INFO><PROGRAM_INFO><PROGRAM_TYPE>",
                 "<XML_DIZ_INFO><PROGRAM_INFO><PROGRAM_INSTALL_SUPPORT>",
                 "<XML_DIZ_INFO><PROGRAM_INFO><PROGRAM_OS_SUPPORT>",
                 "<XML_DIZ_INFO><PROGRAM_INFO><PROGRAM_LANGUAGE>",
                 "<XML_DIZ_INFO><PROGRAM_INFO><PROGRAM_CHANGE_INFO>",
                 "<XML_DIZ_INFO><PROGRAM_INFO><PROGRAM_CATEGORY_CLASS>",
                 "<XML_DIZ_INFO><PROGRAM_INFO><PROGRAM_SYSTEM_REQUIREMENTS>",
                 "<XML_DIZ_INFO><PROGRAM_INFO><FILE_INFO><FILE_SIZE_K>",
                 "<XML_DIZ_INFO><PROGRAM_DESCRIPTIONS><ENGLISH><KEYWORDS>",
                 "<XML_DIZ_INFO><PROGRAM_DESCRIPTIONS><ENGLISH><CHAR_DESC_80>",
                 "<XML_DIZ_INFO><PROGRAM_DESCRIPTIONS><ENGLISH><CHAR_DESC_2000>",
                 "<XML_DIZ_INFO><WEB_INFO><APPLICATION_URLS><APPLICATION_INFO_URL>",
                 "<XML_DIZ_INFO><WEB_INFO><APPLICATION_URLS><APPLICATION_SCREENSHOT_URL>",
                 "<XML_DIZ_INFO><WEB_INFO><APPLICATION_URLS><APPLICATION_ICON_URL>",
                 "<XML_DIZ_INFO><WEB_INFO><APPLICATION_URLS><APPLICATION_XML_FILE_URL>",
                 "<XML_DIZ_INFO><WEB_INFO><DOWNLOAD_URLS><PRIMARY_DOWNLOAD_URL>",
                 "<XML_DIZ_INFO><AFFILIATES><AFFILIATES_ESELLERATE_PRODUCT_ID>",
                 "<XML_DIZ_INFO><AFFILIATES><AFFILIATES_PLIMUS_PRODUCT_ID>",
                 "<XML_DIZ_INFO><AFFILIATES><AFFILIATES_REGNOW_PRODUCT_ID>",
                 "<XML_DIZ_INFO><AFFILIATES><AFFILIATES_SHAREIT_PRODUCT_ID>",
                 "<XML_DIZ_INFO><ASP><ASP_MEMBER_NUMBER>");

$tagstack = "";
$lasttag = "?";

function GetStartTag($parser,$element_name,$element_attribs) {
	global $tagstack;
	$tagstack .= "<" . $element_name . ">";
}

function GetData($parser,$data) {
	global $tagstack, $tagarray, $lasttag;
	if($lasttag == $tagstack) {
		$tagarray["$tagstack"] .= $data;
	}
	else {
		$tagarray["$tagstack"]  = $data;
	}
	$lasttag = $tagstack;
}

function GetEndTag($parser,$element_name) {
	global $tagstack;
	$x = "<" . $element_name . ">";
	if(strrchr($tagstack,$x) == $x) {
		$tagstack = substr($tagstack,0,strrpos($tagstack,$x));
	}
	else {
		die("<p><b>Error:</b> no corresponding start tag for end tag: " . htmlspecialchars($x) . "</p><br>\n");
	}
}

// Reading XML PAD file
if(!($data = @file($padurl))) {
	die("<p><b>Error opening PAD URL.</b><br>Go <a href=\"javascript:history.back()\">Back</a> and check URL.</p><br>\n");
}
$data = implode("",$data);

// Look up the XML encoding
if(preg_match("/<\?xml [^>]*encoding=['\"](.*?)['\"][^>]*>.*/", $data, $encarray)) {
	$encoding = strtoupper($encarray[1]);
}
else {
	$encoding = "UTF-8";
}
// If the encoding is not natively supported by the PHP XML parser, try to
// decode on our own (to UTF-8), if decoding is not possible, assume UTF-8,
// which is the XML default.
if(($encoding != "UTF-8") &&($encoding != "US-ASCII") &&($encoding != "ISO-8859-1")) {
	$encoding = "";
	if(function_exists("mb_convert_encoding")) {
		$encoded_source = @mb_convert_encoding($data, "UTF-8", $encoding);
		if( $encoded_source != NULL ) {
			$data = str_replace($encarray[0], "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>", $encoded_source);
			$encoding = "UTF-8";
		}
	}
}

// Create an XML parser
if(!($xml_parser = xml_parser_create($encoding))) {
	die("<p><b>Error creating XML parser!</b></p><br>\n");
}
// Set ISO-8859-1 as target encoding for XML parser
xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1");

// Set the functions to handle opening and closing tags
xml_set_element_handler($xml_parser,"GetStartTag","GetEndTag");

// Set the function to handle blocks of character data
xml_set_character_data_handler($xml_parser,"GetData");

if(!xml_parse($xml_parser, $data, true)) { // Handle errors in parsing
	$paderr = sprintf("<p><b>XML parsing error:</b> %s at line %d, column %d</p><br>\n", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser), xml_get_current_column_number($xml_parser));
}
// Free up memory used by the XML parser
xml_parser_free($xml_parser);

if($paderr) {
	die($paderr);
}

// Setting defaults if blank
$tag = "<XML_DIZ_INFO><COMPANY_INFO><COUNTRY>";
if(empty($tagarray["$tag"]) or trim($tagarray["$tag"] == "")) $tagarray["$tag"] = "none";

$tag = "<XML_DIZ_INFO><COMPANY_INFO><CONTACT_INFO><CONTACT_FIRST_NAME>";
if(empty($tagarray["$tag"]) or trim($tagarray["$tag"] == "")) $tagarray["$tag"] = "Anonym";

$tag = "<XML_DIZ_INFO><COMPANY_INFO><CONTACT_INFO><CONTACT_LAST_NAME>";
if(empty($tagarray["$tag"]) or trim($tagarray["$tag"] == "")) $tagarray["$tag"] = "Author";

$tag = "<XML_DIZ_INFO><PROGRAM_INFO><PROGRAM_COST_DOLLARS>";
if(empty($tagarray["$tag"]) or trim($tagarray["$tag"] == "")) $tagarray["$tag"] = "0.00";

$tag = "<XML_DIZ_INFO><PROGRAM_INFO><PROGRAM_CHANGE_INFO>";
if(empty($tagarray["$tag"]) or trim($tagarray["$tag"] == "")) $tagarray["$tag"] = "Not Established";

$tag = "<XML_DIZ_INFO><PROGRAM_INFO><PROGRAM_SYSTEM_REQUIREMENTS>";
if(empty($tagarray["$tag"]) or trim($tagarray["$tag"] == "")) $tagarray["$tag"] = "Not Established";

$tag = "<XML_DIZ_INFO><PROGRAM_INFO><PROGRAM_LANGUAGE>";
if(empty($tagarray["$tag"]) or trim($tagarray["$tag"] == "")) $tagarray["$tag"] = "Not Established";

$tag = "<XML_DIZ_INFO><PROGRAM_DESCRIPTIONS><ENGLISH><KEYWORDS>";
if(empty($tagarray["$tag"]) or trim($tagarray["$tag"] == "")) $tagarray["$tag"] = "free, program, download";

$tag = "<XML_DIZ_INFO><WEB_INFO><APPLICATION_URLS><APPLICATION_SCREENSHOT_URL>";
if(empty($tagarray["$tag"]) or trim($tagarray["$tag"] == "")) $tagarray["$tag"] = "none";

$tag = "<XML_DIZ_INFO><WEB_INFO><APPLICATION_URLS><APPLICATION_ICON_URL>";
if(empty($tagarray["$tag"]) or trim($tagarray["$tag"] == "")) $tagarray["$tag"] = "none";

$tag = "<XML_DIZ_INFO><AFFILIATES><AFFILIATES_ESELLERATE_PRODUCT_ID>";
if(empty($tagarray["$tag"]) or trim($tagarray["$tag"] == "")) $tagarray["$tag"] = "none";

$tag = "<XML_DIZ_INFO><AFFILIATES><AFFILIATES_PLIMUS_PRODUCT_ID>";
if(empty($tagarray["$tag"]) or trim($tagarray["$tag"] == "")) $tagarray["$tag"] = "none";

$tag = "<XML_DIZ_INFO><AFFILIATES><AFFILIATES_REGNOW_PRODUCT_ID>";
if(empty($tagarray["$tag"]) or trim($tagarray["$tag"] == "")) $tagarray["$tag"] = "none";

$tag = "<XML_DIZ_INFO><AFFILIATES><AFFILIATES_SHAREIT_PRODUCT_ID>";
if(empty($tagarray["$tag"]) or trim($tagarray["$tag"] == "")) $tagarray["$tag"] = "none";

$tag = "<XML_DIZ_INFO><ASP><ASP_MEMBER_NUMBER>";
if(empty($tagarray["$tag"]) or trim($tagarray["$tag"] == "")) $tagarray["$tag"] = "none";



// Checking for missing/empty tags
$padtagerr = "";
foreach($reqtags as $tag) {
	if(empty($tagarray["$tag"]) or trim($tagarray["$tag"] == "")) {
		$paderr .= "<p><b>Required tag not found in PAD file:</b><br>\n" . htmlspecialchars($tag) . "</p>\n";
		continue;
	}
}
if($paderr) {
	echo $paderr;
	echo "<p><b>PAD file rejected!</b></p><br>";
	exit;
}

$tag = $reqtags[0];  $company         = substr($tagarray["$tag"], 0, 50);
$tag = $reqtags[1];  $country         = substr($tagarray["$tag"], 0, 50);
$tag = $reqtags[2];  $website         = substr($tagarray["$tag"], 0, 128);
$tag = $reqtags[3];  $firstname       = substr($tagarray["$tag"], 0, 64);
$tag = $reqtags[4];  $lastname        = substr($tagarray["$tag"], 0, 64);
$tag = $reqtags[5];  $email           = substr($tagarray["$tag"], 0, 50);
$tag = $reqtags[6];  $title           = substr($tagarray["$tag"], 0, 50);
$tag = $reqtags[7];  $version         = substr($tagarray["$tag"], 0, 15);
$tag = $reqtags[8];  $pmonth          = $tagarray["$tag"];
$tag = $reqtags[9];  $pday            = $tagarray["$tag"];
$tag = $reqtags[10]; $pyear           = $tagarray["$tag"];
$tag = $reqtags[11]; $cost            = $tagarray["$tag"];
$tag = $reqtags[12]; $ptype           = substr($tagarray["$tag"], 0, 15);
$tag = $reqtags[13]; $install         = substr($tagarray["$tag"], 0, 50);
$tag = $reqtags[14]; $os              = substr($tagarray["$tag"], 0, 80);
$tag = $reqtags[15]; $languages       = substr($tagarray["$tag"], 0, 255);
$tag = $reqtags[16]; $changeinfo      = $tagarray["$tag"];
$tag = $reqtags[17]; $category        = substr($tagarray["$tag"], 0, 80);
$tag = $reqtags[18]; $requirements    = substr($tagarray["$tag"], 0, 200);
$tag = $reqtags[19]; $ksize           = $tagarray["$tag"];
$tag = $reqtags[20]; $keywords        = substr($tagarray["$tag"], 0, 128);
$tag = $reqtags[21]; $description     = substr($tagarray["$tag"], 0, 80);
$tag = $reqtags[22]; $descrlarge      = substr($tagarray["$tag"], 0, 2000);
$tag = $reqtags[23]; $homepage        = substr($tagarray["$tag"], 0, 128);
$tag = $reqtags[24]; $screenshot      = substr($tagarray["$tag"], 0, 128);
$tag = $reqtags[25]; $icon            = substr($tagarray["$tag"], 0, 128);
$tag = $reqtags[26]; $padfile         = substr($tagarray["$tag"], 0, 128);
$tag = $reqtags[27]; $download        = substr($tagarray["$tag"], 0, 128);
$tag = $reqtags[28]; $esellerateid    = substr($tagarray["$tag"], 0, 16);
$tag = $reqtags[29]; $plimusid        = substr($tagarray["$tag"], 0, 16);
$tag = $reqtags[30]; $regnowid        = substr($tagarray["$tag"], 0, 16);
$tag = $reqtags[31]; $shareitid       = substr($tagarray["$tag"], 0, 16);
$tag = $reqtags[32]; $aspnumber       = substr($tagarray["$tag"], 0, 5);

// Adding "http://" to links if missing
if((trim($website) != "") && (strstr($website, "://") === FALSE))
	$website = "http://" . $website;
if((trim($homepage) != "") && (strstr($homepage, "://") === FALSE))
	$homepage = "http://" . $homepage;
if((trim($download) != "") && (strstr($download, "://") === FALSE))
	$download = "http://" . $download;

$contactname = $firstname . " " . $lastname;
if(strlen($pmonth) == 1) $pmonth = "0" . $pmonth;
if(strlen($pday) == 1) $pday = "0" . $pday;
$pdate = $pyear . "-" . $pmonth . "-" . $pday;
$ksize = str_replace(",","",$ksize);  // remove any commas

// Checking release date
$tomorrow = date("Y-m-d",time()+86400);
if($pdate > $tomorrow) {
	die("<p><b>Error:</b> Forward dating not allowed. Release date (" . $pdate . ") is greater than tomorrow's date (" . $tomorrow . ")!</p><br>");
}

// Checking PAD URL inside PAD file
if(strcasecmp($padurl,$padfile) != 0) {
	die("<p><b>Error:</b> Submitted URL (" . $padurl . ") does not match URL inside PAD file (" . $padfile . ")!</p><br>");
}

// Checking Category
$catfile = "categories.txt";
$catary = file($catfile);
$isvalidcat = false;
for($i=0; $i<count($catary); $i++) {
	$cdisp = rtrim($catary[$i]);
	if(($category == $cdisp) || ($category == htmlspecialchars($cdisp))) {
		$isvalidcat = true;
		break;
	}
}
if(!$isvalidcat) {
	die("<p><b>Error:</b> Unrecognized category " . $category . "!</p><br>");
}

// Processing affiliate data from submission form or PAD if available
if(!$aflform || !$aflidform) { // if no affiliate data in form established
	if($esellerateid != "none") {
		$affiliate   = "eSellerate";
		$affiliateid = $esellerateid;
	}
	if($plimusid != "none") {
		$affiliate   = "Plimus";
		$affiliateid = $plimusid;
	}
	if($regnowid != "none") {
		$affiliate   = "RegNow";
		$affiliateid = $regnowid;
	}
	if($shareitid != "none") {
		$affiliate   = "Share-It";
		$affiliateid = $shareitid;
	}
	else {
		$affiliate   = "";
		$affiliateid = "";
	}
}
else { // include form data
	$affiliate   = $aflform;
	$affiliateid = $aflidform;
}

$ipaddr        = getenv("REMOTE_ADDR");
$company       = addslashes($company);
$country       = addslashes($country);
$contactname   = addslashes($contactname);
$title         = addslashes($title);
$version       = addslashes($version);
$changeinfo    = addslashes($changeinfo);
$requirements  = addslashes($requirements);
$keywords      = addslashes($keywords);
$description   = addslashes($description);
$descrlarge    = addslashes($descrlarge);
$backlink      = addslashes($backlink);
//$poll          = 0;

// Connecting to database
if(!($link_id = mysql_connect($dbhost, $userid, $userpassword))) {
	die("<p><b>Error connecting to the database server:</b> " . mysql_error() . "</p>\n");
}
mysql_select_db($dbname);

echo "<p><b>PAD URL: " . $padurl . "</b></p>\n";

// Displaying warnings if any
if(($screenshot != "none") && (strstr($screenshot, "://") or (strstr($screenshot, ".gif") && strstr($screenshot, ".jpg") && strstr($screenshot, ".png"))) === FALSE) {
	echo "<p><b>Warning:</b> Path to program screenshot (" . $screenshot . ") must begin with \"http://\" or \"ftp://\" and must take to a single GIF, JPG or PNG image file! Before you correct this, the \"No Screenshot\" image for your listing will be displayed!</b></p><br>\n";
	$screenshot = "none";
}
if(($icon != "none") && (strstr($icon, "://") or (strstr($icon, ".gif") && strstr($icon, ".jpg") && strstr($icon, ".png"))) === FALSE) {
	echo "<p><b>Warning:</b> Path to program icon (" . $icon . ") must begin with \"http://\" or \"ftp://\" and must take to a single GIF, JPG or PNG image file! Before you correct this, the \"No Icon\" image for your listing will be displayed!</b></p><br>\n";
	$icon = "none";
}

// Checking if company/title or PAD URL already in paddata table
$result = mysql_query("SELECT * FROM submitlog WHERE padfile = '$padfile'", $link_id);
$query = mysql_fetch_array($result);
if(empty($query)) { // If there was no such entry in database
	// Adding new software to paddata table
	mysql_query("INSERT INTO submitlog (logtime, ipaddr, company, country, website, contactname, email, title, version, pdate, cost, ptype, install, os, languages, changeinfo, category, requirements, ksize, keywords, description, descrlarge, homepage, screenshot, icon, padfile, download, aspnumber, backlink, affiliate, affiliateid) VALUES (now(), '$ipaddr', '$company', '$country', '$website', '$contactname', '$email', '$title', '$version', '$pdate', '$cost', '$ptype', '$install', '$os', '$languages', '$changeinfo', '$category', '$requirements', '$ksize', '$keywords', '$description', '$descrlarge', '$homepage', '$screenshot', '$icon', '$padfile', '$download', '$aspnumber', '$backlink', '$affiliate', '$affiliateid')", $link_id) or die("<p><b>Error inserting submitlog table:</b> " . mysql_error() . "</p>\n");
	$submid = sprintf("%d", mysql_insert_id($link_id));
	echo "<p>Thank you for your submission, it has been added to our pending submissions list. You will receive a notification message when your software listing is activated.</p><br>\n";
	
	// Sending notification mail about adding new program
	$subject  = $title . " has been added to " . $sitename . " pending submissions list";
	$message  = "Dear " . $contactname . "!\r\n\r\n";
	$message .= "Your software, \"" . $title . " " . $version . "\", has been added to our pending list and will appear on " . $sitename . " and all related sites after approval. If you have placed a backlink to " . $sitename . " on your web site, we will expedite your submission to 2 business days, otherwise it can take up to 2 weeks.\r\n";
	$message .= "If you decide to add the back link after your software has been already submitted, you can simply resubmit it to expedite its approval.\r\n\r\n";
	$message .= "If you have any questions or comments please do not hesitate to contact us at " . $sitemail . " or by filling contact form here: http://" . $_SERVER['HTTP_HOST'] . "/contact.php?subj=authors\r\n\r\n";
	$message .= "Kind regards,\r\n\r\n";
	$message .= $sitename . " webmaster\r\n";
	$headers  = "From: \"" . $sitemail . "\"<" . $sitemail . ">\r\n";
	$headers .= "Reply-To: \"" . $sitemail . "\"<" . $sitemail . ">\r\n";
	$headers .= "Content-Type: text/plain; charset=windows-1252";
}
else {
	$submid       = $query["submid"];
	$affiliate0   = $query["affiliate"];
	$affiliateid0 = $query["affiliateid"];
	
	if($affiliate0 && empty($affiliate))      $affiliate = $affiliate0;
	if($affiliateid0 && empty($affiliateid))  $affiliateid = $affiliateid0;
	
	// Updating the existing entry in submitlog table
	mysql_query("UPDATE submitlog SET logtime = now(), ipaddr = '$ipaddr', company = '$company', country = '$country', website = '$website', contactname = '$contactname', email = '$email', title = '$title', version = '$version', pdate = '$pdate', cost = '$cost', ptype = '$ptype', install = '$install', os = '$os', languages = '$languages', changeinfo = '$changeinfo', category = '$category', requirements = '$requirements', ksize = '$ksize', keywords = '$keywords', description = '$description', descrlarge = '$descrlarge ', homepage = '$homepage', screenshot = '$screenshot', icon = '$icon', padfile = '$padfile', download = '$download', aspnumber = '$aspnumber', backlink = '$backlink', affiliate = '$affiliate', affiliateid = '$affiliateid' WHERE submid = '$submid'", $link_id) or die("<p><b>Error updating submitlog table:</b> " . mysql_error() . "</p>\n");
	echo "<p>Thank you for your submission, it has been updated in our pending submissions list. You will receive a notification message when your software listing is activated.</p><br>\n";
	
	// Sending notification mail about updating of existing program
	$subject  = $title . " has been updated in " . $sitename . " pending submissions list";
	$message  = "Dear " . $contactname . "\r\n\r\n";
	$message .= "Your software, \"" . $title . " " . $version . "\", has been updated in our pending submissions list and will appear on " . $sitename . " and all related sites after approval. If you have placed a backlink to " . $sitename . " on your web site, we will expedite your submission to 2 business days, otherwise it can take up to 2 weeks.\r\n";
	$message .= "If you decide to add the back link after your software has been already submitted, you can simply resubmit it to expedite its approval.\r\n\r\n";
	$message .= "If you have any questions or comments please do not hesitate to contact us at " . $sitemail . " or by filling contact form here: http://" . $_SERVER['HTTP_HOST'] . "/contact.php?subj=authors\r\n\r\n";
	$message .= "Kind regards,\r\n\r\n";
	$message .= $sitename . " webmaster\r\n";
	$headers  = "From: \"" . $sitemail . "\"<" . $sitemail . ">\r\n";
	$headers .= "Reply-To: \"" . $sitemail . "\"<" . $sitemail . ">\r\n";
	$headers .= "Content-Type: text/plain; charset=windows-1252";
}
@mail($email, $subject, $message, $headers);

// Disconnect from database
mysql_close($link_id);

echo "<p>Go <a href=\"javascript:history.back()\">Back</a> to submit another software.</p><br>\n";

?>
<br>

</td><td class="tbody" width="182">

</td>
</tr>
</table>
</td></tr></table>
<?php
include_once('fooder.inc');
?>